<?php
namespace Shopiuu\Model;

use Shopiuu\Http\RequestCore;

class Nav extends Model{
    
    public function __construct($accessToken, $endpoint)
    {
        parent::__construct($accessToken, $endpoint);
    }

    /**
     * getNavMenu
     * @return ResponseCore
     */
    public function getNavMenu()
    {
        $request = $this->getRequest('/openApi/nav/getNavMenu');
        $result = $request->set_method('GET')->send_request(true);
        return $result;
    }

    /**
     * getAllNavLists
     * @return ResponseCore
     */
    public function getAllNavLists()
    {
        $request = $this->getRequest('/openApi/nav/getAllNavLists');
        $result = $request->set_method('GET')->send_request(true);
        return $result;
    }

    /**
     * Create nav
     * @param array $params array(
            [name] => bottom menu
            [code] => bottom_menu
        )
     * @return ResponseCore
     */
    public function add($params)
    {
        $request = $this->getRequest('/openApi/nav/add');
        $result = $request->set_body(json_encode($params))->set_method('POST')->send_request(true);
        return $result;
    }

    /**
     * Modify nav
     * @param array $paramss array(
            [id] => 1
            [name] => bottom menu
            [code] => bottom_menu
        )
     * @return ResponseCore
     */
    public function update($params)
    {
        $request = $this->getRequest('/openApi/nav/update');
        $result = $request->set_body(json_encode($params))->set_method('POST')->send_request(true);
        return $result;
    }

    /**
     * Create menu
     * @param array $params array(
            [name] => bottom menu
            [code] => bottom_menu
        )
     * @return ResponseCore
     */
    public function addMenu($params)
    {
        $request = $this->getRequest('/openApi/nav/addMenu');
        $result = $request->set_body(json_encode($params))->set_method('POST')->send_request(true);
        return $result;
    }

    /**
     * Modify menu
     * @param array $paramss array(
            [id] => 1
            [name] => bottom menu
            [code] => bottom_menu
        )
     * @return ResponseCore
     */
    public function updateMenu($params)
    {
        $request = $this->getRequest('/openApi/nav/updateMenu');
        $result = $request->set_body(json_encode($params))->set_method('POST')->send_request(true);
        return $result;
    }
    /**
     * menuLists
     * @param array $paramss array(
            [id] => 1  //nav id
            [code] => bottom_menu //nav code，optional
        )
     * @return ResponseCore
     */
    public function menuLists($params)
    {
        $request = $this->getRequest('/openApi/nav/menuLists');
        $result = $request->set_body(json_encode($params))->set_method('POST')->send_request(true);
        return $result;
    }
    
    /**
     * Delete nav
     * @param array $params array("id"=>"25")
     * @return ResponseCore
     */
    public function deleteNav($params)
    {
        $request = $this->getRequest('/openApi/nav/deleteNav');
        $result = $request->set_body(json_encode($params))->set_method('POST')->send_request(true);
        return $result;
    }

    /**
     * Delete nav menu
     * @param array $params array("id"=>"25")
     * @return ResponseCore
     */
    public function deleteMenu($params)
    {
        $request = $this->getRequest('/openApi/nav/deleteMenu');
        $result = $request->set_body(json_encode($params))->set_method('POST')->send_request(true);
        return $result;
    }

}